﻿using IntelligentAgriculture.Contracts.Dto.Output;
using IntelligentAgriculture.Contracts.Interface.SheepFileModelInterface;
using IntelligentAgriculture.Domain.Entity;
using IntelligentAgriculture.WebAPI.Application.Command.SheepfilemodelCommand;
using MediatR;

namespace IntelligentAgriculture.WebAPI.Application.CommandHandler.SheepfilemodelCommandHandler
{
    public class SheepfilemodelsGetCommandHandler : IRequestHandler<SheepfilemodelsGetCommand, Results<PageOutput<SheepfilemodelsOutput>>>
    {
        private readonly ISheepFileModelService _sheepFileModelService;

        public SheepfilemodelsGetCommandHandler(ISheepFileModelService sheepFileModelService)
        {
            _sheepFileModelService = sheepFileModelService;
        }

        public async Task<Results<PageOutput<SheepfilemodelsOutput>>> Handle(SheepfilemodelsGetCommand request, CancellationToken cancellationToken)
        {
            var list = await _sheepFileModelService.GetSheepfilemodels(request.Input);
            return Results<PageOutput<SheepfilemodelsOutput>>.DataResult(list);
        }
    }
}
